# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libktorrent
pkgver=2.2.0
_ktorrentver=5.2.0 # $_ktorrentver=ktorrent-$pkgver
pkgrel=0
# armhf blocked by extra-cmake-modules
# mips test failures
arch="all !armhf !mips !mips64"
url="https://kde.org/applications/internet/org.kde.ktorrent"
pkgdesc="A powerful BitTorrent client for KDE"
license="GPL-2.0-or-later"
depends_dev="qt5-qtbase-dev karchive-dev kcrash-dev ki18n-dev kio-dev solid-dev boost-dev gmp-dev qca-dev"
makedepends="$depends_dev extra-cmake-modules doxygen graphviz"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/ktorrent/$_ktorrentver/libktorrent-$pkgver.tar.xz"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	make -C build
	make -C build docs
}

check() {
	cd build
	# utppolltest requires network access
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "utppolltest"
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install

	mkdir -p "$pkgdir"/usr/share/doc
	mv build/apidocs/html "$pkgdir"/usr/share/doc/HTML
}

sha512sums="2edcb3a230f4fa3a55a6b774c819f4964fe8f2f5447b723ba81cdb0c187dc0268b6e78566d710fa364abe2cc40cd618d1874ecb1637e872fbad0ea8c340abc1a  libktorrent-2.2.0.tar.xz"
